﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DXApplicationTangche.UC.订单.service;
using DXApplicationTangche.UC.款式异常;
using DXApplicationTangche.UC.门店下单.form.订单修改;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.样品管理.样品订单预览;
using DevExpress.XtraGrid.Demos.util;
using static DXApplicationTangche.UC.门店下单.form.Frm订单一览;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.订单一览新.订单预览新;
using DXApplicationTangche.UC.门店下单.DTO;
using mendian;

namespace DXApplicationTangche.UC.ImpUC
{
    public partial class XtraUserControl返修订单一览 : DevExpress.XtraEditors.XtraUserControl
    {
        public delegate void AddTabDataEvents(Form form);//定义委托
        private String shopId = "18";
        private String styleId = "";
        private String orderId = "";
        private Enum订单类别 enum订单类别 = Enum订单类别.销售订单;
        //public delegate void AddTabDataEvents(Form form);//定义委托
        public event AddTabDataEvents addTabDataEvents;//定义事件

        public XtraUserControl返修订单一览()
        {
            InitializeComponent();
        }
        public XtraUserControl返修订单一览(String shopId)
        {
            InitializeComponent();
            this.shopId = shopId;
            this.xtraUserControl分页.williamPagerEvent += this.refreshGrid;
            this.refreshGrid(1);
        }
        public void changeShop(String shopId)
        {
            this.shopId = shopId;
        }
        public void refreshGrid(int curPage)
        {
            //从DTO获取数据，绑定数据
            //API只要一行，原子性
            this.gridControl返修订单一览.DataSource = 订单Service.getReworkIndex((curPage - 1).ToString(), "100");
            this.gridView返修订单一览.RefreshData();
        }

        private void gridView返修订单一览_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumnstyleSizeCd"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
            }
        }

        private void gridView返修订单一览_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn返修类型"))
            {
                if ("套号".Equals(e.CellValue.ToString()))
                {
                    e.Appearance.BackColor = Color.LightGreen;
                }
                else if ("春衫SSHIRT".Equals(e.CellValue.ToString()))
                {
                    e.Appearance.BackColor = Color.LightYellow;
                }
                else if ("KASHIYAMA".Equals(e.CellValue.ToString()))
                {
                    e.Appearance.BackColor = Color.Gray;
                }
                else if ("Luna&春衫".Equals(e.CellValue.ToString()))
                {
                    e.Appearance.BackColor = Color.LightPink;
                }
                else if ("样衣".Equals(e.CellValue.ToString()))
                {
                    e.Appearance.BackColor = Color.LightBlue;
                }
            }
        }

        private void 查看订单预览ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.orderId = FunctionHelper.GetgridViewValue(this.gridView返修订单一览, this.gridView返修订单一览.FocusedRowHandle, "orderId");
            if (this.enum订单类别 == Enum订单类别.样品订单)
            {
                new Form样品订单预览新(this.orderId).ShowDialog();
            }
            else
            {
                new Form订单预览新(this.orderId).ShowDialog();
            }
        }
    }
}
